home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / sys / cbm / 4393 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  4.1 KB

  1. Path: seagoon.newcastle.edu.au!usenet
  2. From: "Bruce R. McFarling" <ecbm@cc.newcastle.edu.au>
  3. Newsgroups: comp.sys.cbm,comp.os.misc,alt.comp.hardware.homebuilt,comp.sys.apple2,comp.sys.apple2.programmer,comp.sys.atari.8bit
  4. Subject: Re: 6502 Multitasking OS announce
  5. Date: 22 Mar 1996 07:28:50 GMT
  6. Organization: Department of Economics, University of Newcastle
  7. Message-ID: <4itkri$qlc@seagoon.newcastle.edu.au>
  8. References: <4i94fs$stj@narses.hrz.tu-chemnitz.de> <holger.948.00030EE6@deep.hb.provi.de> <4ijtbe$7ca@no-names.nerdc.ufl.edu> <4ijuic$iiq@gatekeeper.liffe.com> <4innc7$hc4@no-names.nerdc.ufl.edu>
  9. NNTP-Posting-Host: econ70.newcastle.edu.au
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=us-ascii
  12. Content-Transfer-Encoding: 7bit
  13. X-Mailer: Mozilla 1.2N (Windows; I; 16bit)
  14.  
  15. Michael Ellis <michael@anest4.anest.ufl.edu> wrote:
  16.  
  17. >ralph.mason@liffe.com (Ralph Mason) wrote:
  18. >>All well & good BUT the 6502 does not have a relocatable stack pointer
  19. >>so your kinda left with a bit of a problem when it commes to
  20. >>multitasking, ie you cant give each process it's own stack without
  21. >>copying the whole stack ( maybe just to the current sp value? )during
  22. >>each context switch. 
  23.  
  24. >...
  25. >I would consider copying the stack (only the bytes that are actually
  26. >used) during a task switch becase no matter what you do you're going
  27. >to end up copying context-related data at some point. 
  28. >
  29. >Consider the case in which zero-page is used to pass parameters.
  30. >When you switch tasks you will HAVE to preserve the context-sensistive
  31. >parameters by copying them to some area of RAM.  This is not unlike
  32. >copying the stack and, using this approach, you can't take advantage of the capabilities that the stack provides (i.e. recusion,
  33. >parameter passing, etc.).
  34.  
  35.     Here's my reasoning for the two approaches I suggested, that is, 
  36. software stacks relying on absolute X-indexed addressing or post-indexed 
  37. indirect addressing. 
  38.  
  39.     It's a given that in a time-sliced or other non-cooperative task 
  40. switch, the register will be saved. So it makes sense that when the 
  41. parameters for a procedure can be held in the registers, simply pass them 
  42. in that manner. However, that may not suffice for all procedures.
  43.     Use of stacks was suggested as a way to get around this, and 
  44. stacks indeed have all the advantages listed above. There may be problems 
  45. using the hardware stack: the limitation in size (256 byte hard limit) is 
  46. behind many of them.  However, there are other ways to implement stacks 
  47. on the 6502: direct indexing with the index registers permit software 
  48. stacks to be implemented that total 256 x the word width in bytes, so for 
  49. 2 byte stack entries, 512 bytes of software stack space is possible; for 
  50. 4 byte stack entries, 1024 bytes of software stack space is possible.  No 
  51. matter how wide the cells in the stack, by storing each byte of the cell 
  52. in its own binary page, 256 cells can be stacked.
  53.     Advantage: a discussed, the index registers will be saved and 
  54. restored in any task switch, so after setting a task up with the 
  55. appropriate X-value for its segment of the software stack, there is no 
  56. additional task-switching overhead. Compared to PHA PLA, there is a loss 
  57. of one clock in accessing the stack, but in return it is easier to index 
  58. into the stack, to access independent parts of a stack frame.
  59.     Limitations: Fixed 256 cell limit. And, because of the 
  60. peculaiarities of X-indexed addressing, to ensure that X and Y are 
  61. equally useful as indexes, the stacks must be located within page 
  62. boundaries.
  63.  
  64.     To avoid the fixed limit (other than RAM limits), the only 
  65. general indirect addressing modes are (AA,x) and (AA),y, and for handy 
  66. access into the stack, (AA),y is superior (though (AA,x) would give the 
  67. faster task switch).
  68.     Advantage: 16-bit stack pointer with up to 256 bytes per stack 
  69. frame. 
  70.     Disadavantage: in addition to the registers, the location 
  71. providing the stack address would have to be saved and restored in a task 
  72. switch. The accessing is 3 to 5 clocks slower than PHA PLA, depending on 
  73. whether a page address boundary is crossed. And the ability to 
  74. independently point at two stack entries is lost.
  75.  
  76. Virtually,
  77.  
  78. Bruce R. McFarling, Newcastle, NSW
  79. ecbm@cc.newcastle.edu.au
  80.  
  81.